package org.jluzhCS.mylogin.action;

import java.util.Map;

import org.jluzhCS.mylogin.domain.Book;

import ognl.DefaultTypeConverter;

public class BookConverter extends DefaultTypeConverter {

	@Override
	public Object convertValue(Map context, Object value, Class toType) 
	{
		if(toType == Book.class)
		{
			String[] para=(String []) value;
			Book book=new Book();
			String []bookValues=para[0].split(",");
			book.setName(bookValues[0]);
			book.setAuthod(bookValues[1]);
			book.setPrice(bookValues[2]);
			return book;
		}
		else if(toType == String.class)
		{
			Book book = (Book)value;
			return "<" + book.getName() + "," +
					book.getAuthod() + "," +
					book.getPrice() + "<";
		}
		return null;
	}

}
